const {getQR,getResult} = require("../modules/bilibili/login/QRlogin")
const rank = require("../modules/kugou/playlist/rank")
const detail = require("../modules/kugou/playlist/detail")
const play = require("../modules/kugou/play")
const search = require("../modules/kugou/search")
const lrc = require("../modules/kugou/lrc")
var express = require('express');
var router = express.Router();

/* GET users listing. */
router.get('/', function(req, res, next) {
  res.send('respond with a resource');
});

/**
 * 酷狗API···················
 */

/**
 * 歌单推荐
 */
router.get('/list/rank', function(req, res, next) {
  rank().then((r) => {
    res.send(r.data)
  })
});
/**
 * 歌单详情
 */
router.get('/list/detail', function(req, res, next) {
  detail(req.query.id).then((r) => {
    console.log(r.data)
    res.send(r.data)
  })
});

/**
 * 播放地址
 */
router.get('/play', function(req, res, next) {
  play(req.query.id).then((r) => {
    console.log(r.data)
    res.send(r.data)
  })
});
/**
 * 搜索歌曲
 */
router.get('/search', function(req, res, next) {

  search(encodeURI(req.query.keyword)
  ,req.query.page || 1,
      req.query.pagesize || 30
  ).then((r) => {
    console.log(r.data)
    res.send(r.data)
  }).catch((r) => {
    console.log(r)
  })
});

/**
 * 专辑内容
 */
router.get('/search', function(req, res, next) {

  search(encodeURI(req.query.keyword)).then((r) => {
    console.log(r.data)
    res.send(r.data)
  }).catch((r) => {
    console.log(r)
  })
});
/**
 * 专辑内容
 */
router.get('/lrc', function(req, res, next) {
  console.log('kugouLrc')
  console.log(req.query.id)
  lrc(req.query.id,req.query.albumid).then((r) => {
    res.send(r.data)
  }).catch((r) => {
    console.log(r)
  })
});



module.exports = router;
